'use strict';

const Service = require('egg').Service;

class MessageService extends Service {
  constructor(ctx) {
    super(ctx);
    
  }

  async send_sms(mobile,tpl_id,tpl_value) {
    
    
    const result = await this.app.curl('https://sms.yunpian.com/v2/sms/tpl_single_send.json', {
      // 必须指定 method
      method: 'POST',
      // 通过 contentType 告诉 HttpClient 以 JSON 格式发送
      // contentType: 'json',
      data: {
        apikey: this.app.config.sms.apikey,
        mobile: mobile,
        tpl_id:tpl_id,
        tpl_value:tpl_value
      },
      // 明确告诉 HttpClient 以 JSON 格式处理返回的响应 body
      dataType: 'json',
    });


    console.info(result)
    
    

  }
}

module.exports = MessageService;
